#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
  int maxScore(vector<int> &cardPoints, int k)
  {
    int ans = 0, tmp = 0;
    int p;
    int n = cardPoints.size();
    for (int i = -k; i < k; i++)
    {
      p = (n + i) % n;
      tmp += cardPoints[p];
      if (i >= 0)
        tmp -= cardPoints[(i - k + n) % n];
      if (i >= -1)
        ans = max(ans, tmp);
    }
    return ans;
  }
};
int main()
{
  Solution s;

  return 0;
}
